package eu.horyzont.systemyrozproszone.systemmagazynowy.serwer.entities;

/**
 * Base class for persistent objects saved and loaded by a {@link hu.netmind.beankeeper.Store} instance.
 * @author pawel
 */
public abstract class Entity {
    
    private long persistenceId;
    
    public long getId() {
        return persistenceId;
    }
    
    @Override
    public String toString() {
        return String.format("[%s: %d]", this.getClass().getSimpleName(), getId());
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 47 * hash + (int) (this.persistenceId ^ (this.persistenceId >>> 32));
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Entity other = (Entity) obj;
        return this.persistenceId == other.persistenceId;
    }
    
}
